<?php
class View_Rating{
	/**
	 * выводим спискок пользователей в топ
	 */
	public static function displayUsers($arrUsers, $idFolder){
		foreach ($arrUsers as $arrUser){
      if(!empty($arrUser['recount_temp_rating'])){
        $rating =  round($arrUser['recount_temp_rating'], 2);
      }
      elseif(!empty($arrUser['rating'])){
          $rating = round($arrUser['rating'], 2);
      }
      else
          $rating = 0;
      echo '<a name="' . $arrUser['login'] . '"></a>
  			<div class="community_page">
	  			<div class="community_page_bottom">
		  			<div class="community_page_right">
			  			<div class="community_page_left">
				  			<div class="community_page_right_top">
					  			<div class="community_page_right_bootom">
						  			<div class="community_page_left_bottom">
							  			<div class="community_page_left_top">
												<div class="leftPart">
													<div class="avaComm">
														<a href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '"><img align="middle" src="' . W_IMAGES . 'pictures/user/' . (!empty($arrUser['pic_path']) ? ('m_' . $arrUser['ID_user'] . '.' . $arrUser['pic_path']) : 'm_default.gif') . '"/>
													</div>
													<h4 class="fade" title="' . $arrUser['login'] . '"><a href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '">' . $arrUser['login'] . '<i class="fade"></i></a></h4>
												</div>
												<div class="rightPart">
													<h3>Рейтинг: ' . $rating . ' (' . Rating::getUserPlaceByRating($arrUser[self::checkIdFolder($idFolder)], $idFolder) . '-й)</h3>
													<ul class="floatLeft">
														<li>Написано комментариев: <a ' . ($arrUser['comment_amount'] != 0 ? 'href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '/comments"' : 'class="noneLine"') . '>' . $arrUser['comment_amount'] . '</a></li>
														<li>Написано статей: <a ' . ($arrUser['article_amount'] != 0 ? 'href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '/articles"' : 'class="noneLine"') . '>' . $arrUser['article_amount'] . '</a></li>
														<li>Добавлено вопросов: <a ' . ($arrUser['question_amount'] != 0 ? 'href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '/questions"' : 'class="noneLine"') . '>' . $arrUser['question_amount'] . '</a></li>
														<li>Добавлено ответов: <a ' . ($arrUser['answer_amount'] != 0 ? 'href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '/answers"' : 'class="noneLine"') . '>' . $arrUser['answer_amount'] . '</a></li>
														<li>Добавлено готовых решений: <a ' . ($arrUser['solution_amount'] != 0 ? 'href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '/solutions"' : 'class="noneLine"') . '>' . $arrUser['solution_amount'] . '</a></li>
													</ul>
													<ul class="afterFloatLeft">
														<li>Добавлено уроков: <a ' . ($arrUser['lesson_amount'] != 0 ? 'href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '/tutorials"' : 'class="noneLine"') . '>' . $arrUser['lesson_amount'] . '</a></li>
														<li>Друзей: <a ' . ($arrUser['friends_amount'] != 0 ? ' href="' . W_ABSPATH . 'user/' . $arrUser['login'] . '"' : 'class="noneLine"') . '>' . $arrUser['friends_amount'] . '</a></li>
														<li>Оценок: ' . ($arrUser['set_mark_amount'] + $arrUser['difficulty_mark_amount'] + $arrUser['voting_amount']) . '</li>
													</ul>
												</div>
							  			</div>
						  			</div>
					  			</div>
				  			</div>
			  			</div>
		  			</div>
	  			</div>
  			</div>';
  	}
	}
	public static function checkIdFolder($idFolder){
		if ($idFolder == 1 || $idFolder == 2 || $idFolder == 3 || $idFolder == 44)
			return 'recount_temp_rating';
		else 
			return 'rating';
	}
}
?>